const router = require('../../config/router_config')
delete router.index

const reg = /(?<=\/)(.*?)(?=\/)/g

const data = Object.entries(router).reduce((one,two) => {
    let index = two[1].index.match(reg)
    if(!one[index[0]]) one[index[0]] = []
    one[index[0]].push({key: index[1],value: two[0]})
    return one
},{})

for (let [key,items] of Object.entries(data)) {
    const h2 = document.createElement('h2')
    h2.innerText = key
    document.body.append(h2)
    console.log(items)
    items.forEach(item => {
        const a = document.createElement('a')
        a.innerText = item.key
        a.setAttribute('href',`${item.value}.html`)
        document.body.append(a)
        const br = document.createElement('br')
        document.body.append(br)
    })
}
